<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function getAjax(url,type,data){
            //创建XMLHttpRequest对象
            let xhr = new XMLHttpRequest();
            // 注册状态改变的回调函数
            xhr.onreadystatechange = function(){
                if(xhr.readyState === 4){
                    //判断是否成功
                    if(xhr.status>=200&&xhr.status<300){
                        //获取响应数据
                        return xhr.responseText;
                    }else{
                        return "失败"
                    }
                }
            }
                  //打开链接
        xhr.open(type,url);
        //发送请求
        xhr.send();  
        }
        let v =getAjax("http://localhost:3008/api/student/getStudent", "GET", null)
        console.log(v);
        

    
    </script>
</body>
</html>